<template>
	<view class="page">
		<com-header title="浏览记录"></com-header>
		<view class="goods-list">
			<view class="goods-list-item" v-for="(item,index) in historyList" :key="index" @click="toDetail(item.bizpro_id)">
				<view class="goods-img">
					<image :src="item.imgurl"></image>
				</view>
				<view class="goods-info">
					<text class="goods-name">{{item.name}}</text>
					<view class="goods-tag">
						<view class="goods-tag-item" v-for="(item1,index1) in item.label" :key="index1" v-if="index1<2">
							<text>{{item1}}</text>
						</view>
					</view>
					<text class="goods-price">¥ {{item.sale_price}}</text>
					<text class="high-price">原价：{{item.old_price}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import ComHeader from '@/components/ComHeader';
	export default {
		onLoad() {
			this.getUserHistory();
		},
		data() {
			return {
				historyList: []
			}
		},
		components: {
			ComHeader
		},
		methods: {
			toDetail(id) {
			
				uni.navigateTo({
					url: '/pages/goods/GoodsDetail?id='+id
				})
			},
			// 获取用户浏览记录
			getUserHistory() {
				this.$api.getUserHistory().then(res => {
					this.historyList = res.data.data;
					this.labelList = res.data.data.label;
				})
			}
		}
	}
</script>

<style>
	.page {
		width: 100%;
		height: 100vh - (calc(var(--status-bar-height) + 120rpx));
		padding-top: calc(var(--status-bar-height) + 120rpx);
	}
	.goods-list {
		width: 690rpx;
		margin: 0 auto;
	}
	.goods-list-item {
		display: flex;
		justify-content: flex-start;
		align-items: center;
		width: 690rpx;
		height: 200rpx;
		border: 1rpx solid #eee;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
	}
	.goods-img {
		width: 160rpx;
		height: 160rpx;
		margin-left: 20rpx;
	}
	.goods-img image {
		width: 100%;
		height: 100%;
	}
	.goods-info {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		width: 450rpx;
		height: 160rpx;
		margin-left: 40rpx;
	}
	/* .goods-name {
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: rgba(51,51,51,1);
	} */
	.goods-name {
		display: block;
		/* position: absolute; */
		top: 27rpx;
		left: 210rpx;
		/* height: 31rpx; */
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: rgba(51,51,51,1);
		display: -webkit-box;
		-webkit-box-orient: vertical;
		width: 228px;
		font-weight: bold;
		display: -webkit-box;
		overflow: hidden;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
	}
	.goods-tag {
		display: flex;
		margin-top: 5rpx;
	}
	.goods-tag-item {
		display: flex;
		justify-content: center;
		align-items: center;
		margin-right: 20rpx;
		width: auto;
		height: 28rpx;
		background: rgba(222,245,255,1);
		border:1rpx solid rgba(185,233,255,1);
		border-radius: 8rpx;
		padding:0px 6px;
		margin-right:8px;
	}
	.goods-tag-item text {
		font-size: 22rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(72,180,231,1);
	}
	.goods-price {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(254,177,71,1);
		margin-top: 5rpx;
	}
	.high-price {
		font-size: 22rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(153,153,153,1);
		text-decoration: line-through;
	}
</style>
